import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Home from "../views/Home/Home.view.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Home",
    redirect: "/home",
  },
  {
    path: "/test",
    name: "Test",
    component: () => import("../views/Test/Test.view.vue"),
  },
  {
    path: "/home",
    name: "home",
    component: Home,
    meta: {
      name: "123",
      age: "123",
    },
  },
  {
    path: "/book",
    name: "book",
    component: () => import("../views/Book/Book.view.vue"),
  },
  {
    path: "/categorty",
    name: "categorty",
    component: () => import("../views/Test/Test.view.vue"),
  },
  {
    path: "/aboutOur",
    name: "aboutOur",
    component: () => import("../views/Test/Test.view.vue"),
  },
  {
    path: "/ali",
    name: "ali",
    component: () => import("../views/Test/Test.view.vue"),
  },
  {
    path: "/:pathMatch(.*)",
    component: () => import("../views/Test/Test.view.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

//false 不进行导航
// undefined 进行默认导航
// url 跳到对应的url
//对象 类似于router.push({path: '/login', query:...})

router.beforeEach((to, from) => {
  console.log(to);
});

export default router;
